<!DOCTYPE html>
<html>
<head>
    <title>Malware Detection System</title>
    <link rel="stylesheet" href="/static/style.css">
</head>
<body>
    <div class="container">
        <h1>恶意代码检测系统</h1>
        
        <div class="upload-box">
            <input type="file" id="fileInput" accept=".exe,.dll,.bin">
            <button onclick="analyzeFile()">开始扫描</button>
        </div>
        
        <div id="resultPanel" class="hidden">
            <h2>检测结果</h2>
            <div class="result-item">
                <label>文件名称：</label>
                <span id="fileName"></span>
            </div>
            <div class="result-item">
                <label>检测结果：</label>
                <span id="verdict" class="malicious"></span>
            </div>
            <div class="result-item">
                <label>置信度：</label>
                <progress id="confidence" max="1"></progress>
                <span id="confidenceValue"></span>
            </div>
        </div>
    </div>

    <script>
        async function analyzeFile() {
            const file = document.getElementById('fileInput').files[0];
            const formData = new FormData();
            formData.append('file', file);

            try {
                const response = await fetch('/scan', {
                    method: 'POST',
                    body: formData
                });
                
                const result = await response.json();
                document.getElementById('fileName').textContent = result.filename;
                document.getElementById('confidenceValue').textContent = 
                    (result.confidence * 100).toFixed(1) + '%';
                document.getElementById('confidence').value = result.confidence;
                
                const verdictElement = document.getElementById('verdict');
                verdictElement.textContent = result.malicious ? 
                    '⚠️ 发现恶意软件' : '✅ 文件安全';
                verdictElement.className = result.malicious ? 'malicious' : 'clean';
                
                document.getElementById('resultPanel').classList.remove('hidden');
            } catch (error) {
                alert('扫描失败: ' + error.message);
            }
        }
    </script>
</body>
</html> 